package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.sql.Time;
import java.sql.Date;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "task_", schema = "crm")
/**
 * 待办任务与记录
 */
public class Task {
    private int taskId;
    private String taskDescribe;// 行动描述
    private String taskContactName;// 联系人
    private Date taskFinishDate;// 完成日期
    private Time taskTime;// 完成时间--待办任务
    private Integer taskPriority;// 优先--待办任务
    private Integer taskStatus;// 状态--待办任务
    private Date taskCreateDate;// 创建日期--待办任务
    private Integer taskClassify;// 类型--记录
    private Integer taskIs;// 为记录或待办任务
    private Opportunity opportunityByOppId;
    private Maintenance maintenanceByMaiId;//维修工单--记录
    private Customer customerByCustomerId;// 客户
    private Employee employeeByEmpId;// 创建人
    private Employee employeeByExeEmpId;// 执行人
    private List<ChatRecord> chatRecordsByQuotationId;

    @Id
    @Column(name = "task_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getTaskId() {
        return taskId;
    }

    public void setTaskId(int taskId) {
        this.taskId = taskId;
    }


    @Basic
    @Column(name = "task_describe", nullable = true, length = 255)
    public String getTaskDescribe() {
        return taskDescribe;
    }

    public void setTaskDescribe(String taskDescribe) {
        this.taskDescribe = taskDescribe;
    }


    @Basic
    @Column(name = "task_finish_date", nullable = true, length = 255)
    public Date getTaskFinishDate() {
        return taskFinishDate;
    }

    public void setTaskFinishDate(Date taskFinishDate) {
        this.taskFinishDate = taskFinishDate;
    }

    @Basic
    @Column(name = "task_time", nullable = true)
    public Time getTaskTime() {
        return taskTime;
    }

    public void setTaskTime(Time taskTime) {
        this.taskTime = taskTime;
    }

    @Basic
    @Column(name = "task_priority", nullable = true)
    public Integer getTaskPriority() {
        return taskPriority;
    }

    public void setTaskPriority(Integer taskPriority) {
        this.taskPriority = taskPriority;
    }

    @Basic
    @Column(name = "task_status", nullable = true)
    public Integer getTaskStatus() {
        return taskStatus;
    }

    public void setTaskStatus(Integer taskStatus) {
        this.taskStatus = taskStatus;
    }

    @Basic
    @Column(name = "task_create_date", nullable = true, length = 255)
    public Date getTaskCreateDate() {
        return taskCreateDate;
    }

    public void setTaskCreateDate(Date taskCreateDate) {
        this.taskCreateDate = taskCreateDate;
    }


    @Basic
    @Column(name = "task_contact_name", nullable = true, length = 255)
    public String getTaskContactName() {
        return taskContactName;
    }

    public void setTaskContactName(String taskContactName) {
        this.taskContactName = taskContactName;
    }

    @Basic
    @Column(name = "task_classify", nullable = true, length = 255)
    public Integer getTaskClassify() {
        return taskClassify;
    }

    public void setTaskClassify(Integer taskClassify) {
        this.taskClassify = taskClassify;
    }

    @Basic
    @Column(name = "task_is", nullable = true, length = 255)
    public Integer getTaskIs() {
        return taskIs;
    }

    public void setTaskIs(Integer taskIs) {
        this.taskIs= taskIs;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Task task = (Task) o;
        return taskId == task.taskId &&
                Objects.equals(taskDescribe, task.taskDescribe) &&
                Objects.equals(taskFinishDate, task.taskFinishDate) &&
                Objects.equals(taskTime, task.taskTime) &&
                Objects.equals(taskPriority, task.taskPriority) &&
                Objects.equals(taskStatus, task.taskStatus) &&
                Objects.equals(taskCreateDate, task.taskCreateDate) &&
                Objects.equals(taskContactName, task.taskContactName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(taskId, taskDescribe, taskFinishDate, taskTime, taskPriority, taskStatus, taskCreateDate, taskContactName);
    }

    @ManyToOne
    @JoinColumn(name = "opp_id", referencedColumnName = "opp_id")
    public Opportunity getOpportunityByOppId() {
        return opportunityByOppId;
    }

    public void setOpportunityByOppId(Opportunity opportunityByOppId) {
        this.opportunityByOppId = opportunityByOppId;
    }

    @ManyToOne
    @JoinColumn(name = "mai_id", referencedColumnName = "mai_id")
    public Maintenance getMaintenanceByMaiId() {
        return maintenanceByMaiId;
    }

    public void setMaintenanceByMaiId(Maintenance maintenanceByMaiId) {
        this.maintenanceByMaiId = maintenanceByMaiId;
    }

    @ManyToOne
    @JoinColumn(name = "emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByEmpId() {
        return employeeByEmpId;
    }

    public void setEmployeeByEmpId(Employee employeeByEmpId) {
        this.employeeByEmpId = employeeByEmpId;
    }

    @ManyToOne
    @JoinColumn(name = "exe_emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByExeEmpId() {
        return employeeByExeEmpId;
    }

    public void setEmployeeByExeEmpId(Employee employeeByExeEmpId) {
        this.employeeByExeEmpId = employeeByExeEmpId;
    }


    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }
    @OneToMany(mappedBy = "taskByTaskId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<ChatRecord> getChatRecordsByQuotationId() {
        return chatRecordsByQuotationId;
    }

    public void setChatRecordsByQuotationId(List<ChatRecord> chatRecordsByQuotationId) {
        this.chatRecordsByQuotationId = chatRecordsByQuotationId;
    }
}
